/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1628610590309_1912';

  // add your middleware config here
  config.middleware = [
    'checkLogin',
  ];
  config.checkLogin = {
    filter: [
      '/',
      '/api/user/login',
      '/api/user/register',
      '/api/connect',
      '/api/row/query',
      '/api/field/query',
    ],
  };

  config.mysql = {
    // 单数据库信息配置
    client: {
      // host
      host: '127.0.0.1',
      // 端口号
      port: '3306',
      // 用户名
      user: 'root',
      // 密码
      password: 'root',
      // 数据库名
      database: 'haiyan',
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  config.view = {
    defaultViewEngine: 'nunjucks',
    mapping: {
      '.html': 'nunjucks',
    },
  };

  config.security = {
    csrf: {
      headerName: 'x-csrf-token', // 通过 header 传递 CSRF token 的默认字段为 x-csrf-token
    },
  };
  config.bodyParser = {
    formLimit: '50mb',
    jsonLimit: '50mb',
    textLimit: '50mz'
  };
  config.session = {
    key: 'q232djv5e58',
    maxAge: 1 * 60 * 60 * 1000, // 1h
    httpOnly: true,
    signed: true,
    encrypt: true,
    renew: true,
  };
  config.multipart = {
    fileSize:'50mb',
    mode:'file',
    fileExtensions:['.png','.jpg']
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
